<template>
    <table class="table-bordered" border="1">
        <tr>
            <td>房号名称</td>
            <td>
                <input type="text" v-model="RN.rnumber_Name">
            </td>
        </tr>
         <tr>
            <td>所属楼层</td>
            <td>
                  <input type="text" v-model="RN.rnumber_Floor">
            </td>
        </tr>
         <tr>
            <td>具体房号</td>
            <td>
                  <input type="text" v-model="RN.rnumber_Num">
            </td>
        </tr>
         <tr>
            <td>房号状态</td>
            <td>
                  <input type="radio" name="state" :value="true" v-model="RN.rnumber_State">上架
                  <input type="radio" name="state" :value="false" v-model="RN.rnumber_State">下架
            </td>
        </tr>
         <tr>
           
            <td colspan="2">
                <input type="button" value="添加" @click="AddRoomNumber">
            </td>
        </tr>
    </table>
</template>

<script setup lang="ts">
import { ref } from "vue";
import axios from "axios";

const RN = ref({
  rnumber_Id: 0,
  rnumber_Name: "",
  rnumber_Floor: 0,
  rnumber_Num: "",
  rnumber_State: true,
  rname_DelState: true,
});

const AddRoomNumber = () => {
    axios.post('https://localhost:7071/api/RoomNumber/AddRoomNumber', RN.value)
        .then(res => {
            if (res.data > 0) {
            alert('添加成功')
            }
            else if (res.data==-1) {
              alert('房号已存在')
            }
            else {
              alert('添加失败')
        }
    })
}
</script>

<style scoped>
</style>